package org.skyeye.modeling.customerized.model;

import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.skyeye.modeling.tools.STextPropertyDescriptor;

public class AVOutput extends SimpleOutput {

	private static Image LIVE_ICON = createImage(AVOutput.class, "icons/live16.gif"); //$NON-NLS-1$
	static final long serialVersionUID = 1;
	public static String TERMINAL_OUT_P = "OUT_P"; 
	public static String TERMINAL_OUT_N = "OUT_N"; 
	
	public static String ID_V_VALUE = "V_VALUE";
	public static String ID_HZ_VALUE = "HZ_VALUE";
	public static String ID_PCT_VALUE = "PC_VALUE";
	private String v_value = "10";
	private String hz_value = "50";
	private String pct_value = "10";
	protected  IPropertyDescriptor[] newDescriptors = null;
	
	public AVOutput(){
		newDescriptors = new IPropertyDescriptor[3] ;
		STextPropertyDescriptor pValueProp = new STextPropertyDescriptor(ID_V_VALUE, "Vota","1");
		//pValueProp.setValidator(LogicNumberCellEditorValidator.instance());
		newDescriptors[0] = pValueProp;
		
		STextPropertyDescriptor pValueProp2 = new STextPropertyDescriptor(ID_HZ_VALUE, "Hz","1");
		//pValueProp2.setValidator(LogicNumberCellEditorValidator.instance());
		newDescriptors[1] = pValueProp2;
		
		STextPropertyDescriptor pValueProp3 = new STextPropertyDescriptor(ID_PCT_VALUE, "Pct","1");
		//pValueProp3.setValidator(LogicNumberCellEditorValidator.instance());
		newDescriptors[2] = pValueProp3;
		
	}
	public Image getIconImage() {
		return LIVE_ICON;
	}

	public String toString() {
		return "V";
	}

	public Object getPropertyValue(Object propName) {
		if (ID_V_VALUE.equals(propName)){
			return getV_value();
		}else if(ID_HZ_VALUE.equals(propName)){
			return this.getHz_value();
		}else if(ID_PCT_VALUE.equals(propName)){
			return this.getPct_value();
		}else{
			return super.getPropertyValue(propName);
		}
	}
	public void setPropertyValue(Object id, Object value) {
		if (ID_V_VALUE.equals(id)){
			setV_value((String)value);
		}else if(ID_HZ_VALUE.equals(id)){
			this.setHz_value((String) value);
		}else if(ID_PCT_VALUE.equals(id)){
			this.setPct_value((String) value);
		}else{
			super.setPropertyValue(id, value);
		}
	}
	
	public String getV_value() {
		return v_value;
	}
	public void setV_value(String v_value) {
		this.v_value = v_value;
	}
	public String getHz_value() {
		return hz_value;
	}
	public void setHz_value(String hz_value) {
		this.hz_value = hz_value;
	}
	public String getPct_value() {
		return pct_value;
	}
	public void setPct_value(String pct_value) {
		this.pct_value = pct_value;
	}
	public void update() {
		setOutput(TERMINAL_OUT_P, true);
		setOutput(TERMINAL_OUT_N, false);
		System.out.println("SimpleOutput notify " + getResult());
	}
	public IPropertyDescriptor[] getPropertyDescriptors() {
		return newDescriptors;
	}
	@Override
	public boolean getResult() {
		return false;
	}
}
